from collections import Iterable as it
from functools import reduce
def first():
    for a in 'ABF':
        print(a)
# def aaa():
#     aa=isinstance('abc',it.Iterable)
#     print(aa)
def b():
    for a in [cc+dd for cc in range(2,23) if cc % 2==0 for dd in range(3,24) if dd % 2 !=0]:
        print(a)
# b()
def c():
    for a in [b+'='+c for b,c in {'name':'chenhui','age':'23'}.items()]:
        print(a)
def d (max):
    a,b,c=0,0,1
    while a<max:
        yield c
        b,c=b,b+c
        a=a+1
    return 'done'
# print(iter(['a','b']))
def dd(a):
    return a*a

def _odd_iter():
    n = 1
    while True:
        n = n + 2
        yield n
def _not_divisible(n):
    return lambda x: x % n > 0
def primes():
    yield 2
    it = _odd_iter() # 初始序列
    while True:
        n = next(it) # 返回序列的第一个数
        yield n
        it = filter(_not_divisible(n), it) # 构造新序列

if __name__ == '__main__':
    print([a for a in d(9)])
    print([a for a in map(lambda cc:cc+cc,[1,2,3,4])])
    # print([a for a in reduce(lambda a,b:a*10+b,map(lambda cc:cc*2+cc,range(6)))])
    for n in primes():
        if n < 1000:
            print(n)
        else:
            break
    print(sorted(['bob', 'about', 'Zoo', 'Credit'], key=str.lower, reverse=True))
